<?php

/**
 * 缓存操作类
 * Class cache
 */
class cache{
    private $cacheobj = null;

    public function __construct($cache_method='default')
    {
        $cache_config = load_config('cache');
        if(isset($cache_config[$cache_method])){
            $this->cacheobj =  load_class($cache_config[$cache_method]['type']);
        }
    }

    public function set($key, $val, $ttl=0){
        return $this->cacheobj ->set($key, $val, $ttl);
    }

    public function get($key)
    {
        return $this->cacheobj->get($key);
    }

    public function delete($key)
    {
        return $this->cacheobj->delete($key);
    }

    public function clean()
    {
        return $this->cacheobj->clean();
    }

}